package com.huluobo.report

import com.huluobo.lib_base.BaseViewModel
import com.huluobo.lib_base.Res
import com.huluobo.lib_base.UIIntent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 *  Created by LC on 2025/1/16.
 */
@HiltViewModel
class ReportViewModel @Inject constructor(private val reportRepo: ReportRepo) : BaseViewModel<ReportIntent>() {
    override fun handleIntent(intent: UIIntent) {
        when (intent) {
            is ReportIntent.getReport -> {
                httpRequest(reportRepo.getReport() as Flow<Res<Any>>)
            }

            is ReportIntent.addReport -> {
                httpRequest(reportRepo.addReport(intent.map) as Flow<Res<Any>>)
            }
        }
    }
}